<?php

class order_payment extends a_dynamic_prop {

    public function get_property_name() {
        return $this->_prefix() . "order_payment_obj";
    }

    public function run(i_base_model $caller) {
        //@TO_DO : std object would have many other properties to more information about the payment driver used
        if ($caller->id !== NULL) {
            $std = new stdClass();
            $payment_manager = new payment_manager();
            $base_info = $payment_manager->get_payment_info($caller->id);
            if ($base_info !== NULL) {
                $std = $base_info->convert_to_simple_data();
                $payment_driver = $payment_manager->get_payment_driver($base_info->payment_driver_id);
                if ($payment_driver !== NULL) {
                    $std->transactional_info =  $payment_driver->get_payment_transactional_info($caller);
                    unset($payment_driver);
                }
                return $std;
            }else{
                return NULL;
            }
            unset($payment_manager);
            
        } else {
            return NULL;
        }
    }

    public function for_model() {
        return "order_m_order";
    }

    public function run_once() {
        return FALSE;
    }

}

?>